import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class MyServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置字符编码
        request.setCharacterEncoding("utf8");
        //从 request 对象中获取username,password
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        request.setAttribute("username","444");
        request.setAttribute("password",password);
        request.getRequestDispatcher( "/new.jsp").forward(request, response);
    }
}
